package com.ys.service.hr.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ys.dto.AddDto;
import com.ys.entity.hr.ThrUserArchives;
import com.ys.entity.hr.ThrUserArchivesRecord;
import com.ys.entity.sys.YsCol;
import com.ys.mapper.hr.ThrUserArchivesMapper;
import com.ys.mapper.hr.ThrUserArchivesRecordMapper;
import com.ys.service.hr.ThrUserArchivesRecordService;
import com.ys.service.hr.ThrUserArchivesService;
import com.ys.util.CheckUtil;
import com.ys.vo.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;

@Service("thrUserArchivesRecordService")
public class ThrUserArchivesRecordServiceImpl implements ThrUserArchivesRecordService {
	private static final Logger logger = LoggerFactory.getLogger(ThrUserArchivesRecordServiceImpl.class);

	@Autowired
	private ThrUserArchivesRecordMapper thrUserArchivesRecordMapper;


	/**
	 * 新增
	 */
	@Override
	public R add(Map<String, Object> params) throws Exception{
		ThrUserArchivesRecord thrUserArchivesRecord = JSON.parseObject(JSON.toJSONString(params), ThrUserArchivesRecord.class);
		thrUserArchivesRecord.setStatus(1);

		int result = thrUserArchivesRecordMapper.insert(thrUserArchivesRecord);

		return R.ok();
	}

	/**
	 * 修改
	 */
	@Override
	public R update(Map<String, Object> params) throws Exception{
		ThrUserArchivesRecord thrUserArchivesRecord = JSON.parseObject(JSON.toJSONString(params), ThrUserArchivesRecord.class);
		thrUserArchivesRecord.setStatus(1);

		int result = thrUserArchivesRecordMapper.update(thrUserArchivesRecord);

		return R.ok();
	}

	//删除
	@Override
	public R del(Long id)throws Exception{
		thrUserArchivesRecordMapper.deleteTrue(id);
		return R.ok();
	}

}
